package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 酒店控制类
 *
 * @Author Json.D
 * @Date 2022/8/6 17:44
 * @Blog
 * @Description: 酒店控制类
 */
@RestController
@RequestMapping("hotel")
public class HotelController {

    @Autowired
    IHotelService iHotelService;

    /**
     * 首页分页，并按照条件查询
     *
     * @param params
     * @return
     */
    @PostMapping("list")
    public PageResult<HotelDoc> list(@RequestBody RequestParams params) {
        PageResult<HotelDoc> page = iHotelService.getList(params);

        return page;
    }
    @PostMapping("filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams params){
        return iHotelService.filters(params);
    }

    /**
     * 自动补全功能
     * @param prefix
     * @return
     */
    @GetMapping("suggestion")
    public List<String> getSuggestions(@RequestParam("key") String prefix) {
        return iHotelService.getSuggestions(prefix);
    }
}
